#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://oj33.cn/contest.php?cid=1075
//https://blog.csdn.net/qq_37482202/article/details/89513877

const int Man=33;
int matchlist[Man][Man];
int m;
int main()
{
	cin >> m;
	int n = 1 << m;
	int k = 1, half = 1;
	matchlist[0][0] = 1;
	while (k <= m)
	{
		for (int i = 0; i < half; i++)
		{
			for (int j = 0; j <= half; j++)
			{
				matchlist[i][j + half] = matchlist[i][j] + half;
			}
			for (int i = 0; i < half; i++)
			{
				for (int j = 0; j < half; j ++)
				{
					matchlist[i+half][j] = matchlist[i][j+half];
					matchlist[half+i][half+j] = matchlist[i][j];


				}
				half=half << 1;
				k++;

			}
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					cout << matchlist[i][j] << " ";
				}cout << endl;
			}
		}
	}
	return 0;
}